/**
 * @description 定时任务管理
 * @author lzy
 * @since 2021/12/29
 */

import { ServiceApi } from "/@/api/_base/service-api";
import service from "/@/utils/request";

class JobSchedulerServiceApi extends ServiceApi {
    /**
     * 得到未来近几次的执行时间
     * @param cronExpression 
     * @param numTimes 
     * @returns 
     */
    getCronNextTime(cronExpression: String, numTimes: any) {
        let url = this.baseUrl + "/getNextTime";
        let params = {
            cronExpression: cronExpression,
            numTimes: numTimes
        }
        return service.get(url, {params: params})
    }

    /**
     * 修改任务状态
     * @param jobId 
     * @returns 
     */
    changeJobStatus(jobId: String) {
        let url = this.baseUrl + "/changeJobStatus";
        let params = {
            jobId: jobId,
        }
        return service.get(url, {params: params})
    }

    /**
     * 执行一次任务
     * @param jobId 
     * @returns 
     */
    runOnceJob(jobId: String) {
        let url = this.baseUrl + "/runOnceJob";
        let params = {
            jobId: jobId,
        }
        return service.get(url, {params: params})
    }
}
const jobSchedulerServiceApi = new JobSchedulerServiceApi("/rest/jobscheduler/JobSchedulerService");

export default jobSchedulerServiceApi;